package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "web_order", schema = "web_mojianworld_server", catalog = "")
public class WebOrder
    extends BaseForm {
  /**
   * 待支付
   */
  public static final int STATUS_WAIT_PAY = 1;
  /**
   * 已支付
   */
  public static final int STATUS_PAY_END = 2;
  /**
   * 等待发货
   */
  public static final int STATUS_WAIT_SEND = 3;
  /**
   * 运送中
   */
  public static final int STATUS_SEND_END = 4;
  /**
   * 已签收
   */
  public static final int STATUS_USER_TAKE = 5;

  /**
   * 退货
   */
  public static final int STATUS_SALE_BACK = 6;




  public String orderId;
  @Rules(fieldName = "产品ID", min = "0")
  public int productId;
  public String productName;
  @Rules(fieldName = "购买数量", min = "0")
  public int buyNum;
  @Rules(fieldName = "下单时的总价")
  public BigDecimal totalPrice;
  @Rules(fieldName = "下单时的产品终价")
  public BigDecimal finalPrice;
  @Rules(fieldName = "购买时用户选择的产品属性", required = false)
  public String template;
  public Date createDate;
  public Date updateDate;
  @Rules(fieldName = "买家留言", required = false)
  public String userNote;
  public String userId;
  @Rules(fieldName = "收获地址的记录ID", min = "0")
  public int addressId;
  public String transportId;
  public int orderStatus;
  public int transportStatus;

  public String transactionId;

  @Id
  @Column(name = "orderId", nullable = false, length = 50)
  public String getOrderId() {
    return orderId;
  }

  public void setOrderId(String orderId) {
    this.orderId = orderId;
  }

  @Basic
  @Column(name = "productId", nullable = false)
  public int getProductId() {
    return productId;
  }

  public void setProductId(int productId) {
    this.productId = productId;
  }

  @Basic
  @Column(name = "productName", nullable = false, length = 50)
  public String getProductName() {
    return productName;
  }

  public void setProductName(String productName) {
    this.productName = productName;
  }

  @Basic
  @Column(name = "buyNum", nullable = false)
  public int getBuyNum() {
    return buyNum;
  }

  public void setBuyNum(int buyNum) {
    this.buyNum = buyNum;
  }

  @Basic
  @Column(name = "totalPrice", nullable = false, precision = 2)
  public BigDecimal getTotalPrice() {
    return totalPrice;
  }

  public void setTotalPrice(BigDecimal totalPrice) {
    this.totalPrice = totalPrice;
  }

  @Basic
  @Column(name = "finalPrice", nullable = false, precision = 2)
  public BigDecimal getFinalPrice() {
    return finalPrice;
  }

  public void setFinalPrice(BigDecimal finalPrice) {
    this.finalPrice = finalPrice;
  }

  @Basic
  @Column(name = "template", nullable = true, length = 400)
  public String getTemplate() {
    return template;
  }

  public void setTemplate(String template) {
    this.template = template;
  }

  @Basic
  @Column(name = "createDate", nullable = false)
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  @Basic
  @Column(name = "updateDate", nullable = true)
  public Date getUpdateDate() {
    return updateDate;
  }

  public void setUpdateDate(Date updateDate) {
    this.updateDate = updateDate;
  }

  @Basic
  @Column(name = "userNote", nullable = true, length = 200)
  public String getUserNote() {
    return userNote;
  }

  public void setUserNote(String userNote) {
    this.userNote = userNote;
  }

  @Basic
  @Column(name = "userId", nullable = false, length = 36)
  public String getUserId() {
    return userId;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  @Basic
  @Column(name = "addressId", nullable = false)
  public int getAddressId() {
    return addressId;
  }

  public void setAddressId(int addressId) {
    this.addressId = addressId;
  }

  @Basic
  @Column(name = "transportId", nullable = true, length = 50)
  public String getTransportId() {
    return transportId;
  }

  public void setTransportId(String transportId) {
    this.transportId = transportId;
  }

  @Basic
  @Column(name = "orderStatus", nullable = false)
  public int getOrderStatus() {
    return orderStatus;
  }

  public void setOrderStatus(int orderStatus) {
    this.orderStatus = orderStatus;
  }

  @Basic
  @Column(name = "transportStatus", nullable = false)
  public int getTransportStatus() {
    return transportStatus;
  }

  public void setTransportStatus(int transportStatus) {
    this.transportStatus = transportStatus;
  }

  @Basic
  @Column(name = "transactionId", nullable = false, length = 36)
  public String getTransactionId() {
    return transactionId;
  }

  public void setTransactionId(String transactionId) {
    this.transactionId = transactionId;
  }


  @Override
  public int hashCode() {
    int result = orderId != null ? orderId.hashCode() : 0;
    result = 31 * result + productId;
    result = 31 * result + (productName != null ? productName.hashCode() : 0);
    result = 31 * result + buyNum;
    result = 31 * result + (totalPrice != null ? totalPrice.hashCode() : 0);
    result = 31 * result + (finalPrice != null ? finalPrice.hashCode() : 0);
    result = 31 * result + (template != null ? template.hashCode() : 0);
    result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
    result = 31 * result + (updateDate != null ? updateDate.hashCode() : 0);
    result = 31 * result + (userNote != null ? userNote.hashCode() : 0);
    result = 31 * result + (userId != null ? userId.hashCode() : 0);
    result = 31 * result + addressId;
    result = 31 * result + (transportId != null ? transportId.hashCode() : 0);
    result = 31 * result + orderStatus;
    result = 31 * result + transportStatus;
    result = 31 * result + (transactionId != null ? transactionId.hashCode() : 0);
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
